<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <link href="css/bootstrap.css" rel="stylesheet">
                <link href="css/shop-homepage.css" rel="stylesheet"> 
		<script src="js/jquery-1.10.2.js"></script>
                <script src="js/bootstrap.js"></script>
		<script src="js/handlebars-v1.3.0.js"></script>
		<script src="js/product.js"></script>
    </head>
    <body>
       <div id="pageHeader"></div>

       <div class="container">
           
           <div class="row">

                    <div class="col-sm-12">
                         <h1 class="page-header">Online Basket
                        <small>Store Inventory
                       </small>
                        </h1>
                    </div>

        </div>
           
           
        <div class="well col-lg-10 col-md-offset-1">

        
        <table class="table-striped text-center text-primary" width='100%' id='invList'>
            <tr class="h4 text-warning">
                <td>Product Id</td>
                <td>Name</td>
                <td>Price</td>
                <td>Total Quantity</td>
                <td>Type</td>
            </tr>

        </table>
        </div>
           
           <div class="col-lg-10 col-lg-offset-5">
               <a href ="onlineMarket/Inventory">Get Store Inventory List in JSON format</a>
           </div>
      
       
       </div>
        
            
          
        
         <div class="container" id="footer">
        </div>
        <script type="text/javascript">
                    
             $(function(){
                 
                    var promise= $.getJSON("onlineMarket/Inventory");            
                    
                    promise.done(function(result){
                        
                        var d = JSON.stringify(result);
                        $("#d").text(d);
                        var obj = $.parseJSON(d);
                        
                        for (var i=0;i<obj.items.length;i++)
                            $("#invList").append(
                                $("<tr/>").append(
                                $("<td/>").text(obj.items[i].pId)).append(
                                $("<td/>").text(obj.items[i].pName)).append(
                                $("<td/>").text((obj.items[i].pPrice).toFixed(2))).append(
                                $("<td/>").text(obj.items[i].pQty)).append(
                                $("<td/>").text(obj.items[i].pType)));
                    });
                
             });
            
            
        </script>
    </body>
</html>
